<html><head><title>ListIndex</title></head>
<body bgcolor="#FFFFDF" link="#009999" vlink="#006666" alink="#006666">
<font face="Arial" size="2"><p align="center"><b><font size="4">ListIndex()</font></b></p>
<p><b>Syntax</b></p><blockquote>
Index = <font color="#006666"><b>ListIndex</b></font>(List()) </blockquote>

</blockquote>
<b>Description</b><br><blockquote>

Find out the position of the current element in the list, considering that the first element 
is at the position 0. This function is very fast, and can be used a lot without performance 
issue (it doesn't iterate the list but uses a cached value). 

</blockquote><p><b>Parameters</b></p><blockquote>
<style type="text/css">
table.parameters { border-spacing: 0px; border-style: none; border-collapse: collapse; }
table.parameters td { border-width: 1px; padding: 6px; border-style: solid; border-color: gray; vertical-align: top; font-family:Arial; font-size:10pt; }
</style>
<table width="90%" class="parameters">
<tr><td width="10%"><i>List()</i></td>
<td width="90%"> 
The name of your list variable, created with the <a href="../reference/newlist.html">NewList</a> function. 
You must include the brackets after the list name. 

</td></tr>
</table>
</blockquote><p><b>Return value</b></p><blockquote>

A number containing the position of the current element within the list. The first 
element is at position 0, the next at 1 and so on. A value of -1 means there is no 
current element (either the list is empty or <a href="resetlist.html">ResetList()</a> has been used). 

</blockquote><p><b>Example</b></p><blockquote>

<pre><font face="Courier New, Courier, mono"size="2">  <b><font color="#006666">NewList</font></b> <font color="#006666">fruit</font>.s()

<font color="#006666">  AddElement</font>(<font color="#006666">fruit</font>()) :<font color="#006666"> fruit</font>() = "oranges"
<font color="#006666">  AddElement</font>(<font color="#006666">fruit</font>()) :<font color="#006666"> fruit</font>() = "bananas"
<font color="#006666">  AddElement</font>(<font color="#006666">fruit</font>()) :<font color="#006666"> fruit</font>() = "apples"
<font color="#006666">  AddElement</font>(<font color="#006666">fruit</font>()) :<font color="#006666"> fruit</font>() = "pears"

<font color="#006666">  FirstElement</font>(<font color="#006666">fruit</font>())
<font color="#006666">  MessageRequester</font>("Fruit: "+<font color="#006666">fruit</font>(), "Now at position "+<font color="#006666">Str</font>(<font color="#006666">ListIndex</font>(<font color="#006666">fruit</font>())),  <font color="#924B72">#PB_MessageRequester_OK</font>)

<font color="#006666">  NextElement</font>(<font color="#006666">fruit</font>())
<font color="#006666">  MessageRequester</font>("Fruit: "+<font color="#006666">fruit</font>(), "Now at position "+<font color="#006666">Str</font>(<font color="#006666">ListIndex</font>(<font color="#006666">fruit</font>())),  <font color="#924B72">#PB_MessageRequester_OK</font>)

<font color="#006666">  NextElement</font>(<font color="#006666">fruit</font>())
<font color="#006666">  MessageRequester</font>("Fruit: "+<font color="#006666">fruit</font>(), "Now at position "+<font color="#006666">Str</font>(<font color="#006666">ListIndex</font>(<font color="#006666">fruit</font>())),  <font color="#924B72">#PB_MessageRequester_OK</font>)

<font color="#006666">  NextElement</font>(<font color="#006666">fruit</font>())
<font color="#006666">  MessageRequester</font>("Fruit: "+<font color="#006666">fruit</font>(), "Now at position "+<font color="#006666">Str</font>(<font color="#006666">ListIndex</font>(<font color="#006666">fruit</font>())),  <font color="#924B72">#PB_MessageRequester_OK</font>)
</font></pre>

</blockquote><p><b>See Also</b></p><blockquote>

<a href="selectelement.html">SelectElement()</a>, <a href="listsize.html">ListSize()</a> 

</Blockquote><p><b>Supported OS </b><Blockquote>All</Blockquote></p><center><- <a href=lastelement.html>LastElement()</a> - <a href=index.html>List Index</a> - <a href=listsize.html>ListSize()</a> ->

</body></html>